﻿@model string
<div class="current-location">
    <ul>
        <li class="left"><i class="glyphicon glyphicon-home"></i><a href="javascript:void(0)" onclick="location.href=location.href">系统表管理</a></li>
        <li class="right"><a href="javascript:void(0)" onclick="LoadData()" title="刷新"><span class="glyphicon glyphicon-refresh"></span></a></li>
    </ul>
</div>
<div class="main">
    <table border=0 cellpadding=0 cellspacing=0 class="tb-head form-inline form-group-sm">
        <tr>
            <td align="left">
                <div class="btn-group btn-group-sm">
                    <button type="button" class="btn btn-default ui-selectInvert">反选</button>
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                        菜单
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li>
                            <a href="javascript:void(0)" class="ui-dialog" data-custom-params="title:'添加',url:'@Url.ActionUrl("Add")',width:'680px',height:'420px'">添加</a>
                        </li>
                    </ul>
                </div>
            </td>
            <td align="right">
                <select id="search_name" name="search_name" class="form-control form-control-xs ui-queryString ui-setName">
                    <option value="name">按表名搜索</option>
                    <option value="remark">按标识搜索</option>
                </select>
                <input type="text" id="name" name="name" maxlength="20" class="form-control ui-keyword ui-queryString" style="width:120px;">
                <button class="btn btn-default btn-sm ui-queryString-search" type="button">确定</button>
            </td>
        </tr>
    </table>
    <table border=0 cellpadding=0 cellspacing=0 class="table table-bordered form-inline form-group-sm" id="tb_list">
        <thead>
            <tr>
                <td style="width:40px"><input type="checkbox" title="选择" class="ui-selectInvert" data-custom-params="isReverse:false"></td>
                <td align="center">表名</td>
                <td align="center">标识</td>
                <td align="center">可扩展</td>
                <td align="center">删除保护</td>
                <td align="center">预定义字段</td>
                <td align="center">自定义字段</td>
                <td align="center">操作</td>
            </tr>
        </thead>
        <tr class="item list-template-item" id="item_{id}" can_expand="{can_expand}" delete_protect="{delete_protect}">
            <td align="center"><input type="checkbox"class="checked-item" value="{id}"></td>
            <td align="center">{name}</td>
            <td align="center">{remark}</td>
            <td align="center"><span class="lb_can_expand">{canExpand}</span></td>
            <td align="center"><span class="lb_delete_protect">{deleteProtect}</span></td>
            <td align="center">
                <button type="button" data-custom-params="url:'@Url.ActionUrl("Set")?table={name}',title:'{remark}-预定义字段管理'" class="btn btn-default btn-sm ui-dialog">配置</button>
            </td>
            <td align="center">
                <button type="button" data-custom-params="title:'{remark}-自定义字段管理',url:'@Url.ActionUrl("Index","Field")?tableName={name}'" class="btn btn-default btn-sm ui-dialog btn_field_admin">管理</button>
            </td>
            <td align="center">
                <div class="btn-group btn-group-sm">
                    <a href="javascript:void(0)" class="btn btn-default ui-dialog" data-custom-params="title:'{remark}-修改',url:'@Url.ActionUrl("Edit")?id=0&table={name}',width:'680px',height:'420px'" title="修改">修改</a>
                    <a href="javascript:void(0)" class="btn btn-default ui-deleteSingle" data-custom-params="url:'@Url.ActionUrl("Delete")',id:'0',addParams:'table={name}',callBack:'LoadData'" title="删除">删除</a>
                </div>
            </td>
        </tr>
    </table>

</div>
<script type="text/javascript">
    function LoadData(params) {
        $("#tb_list").ListBind({url:"@Url.ActionUrl("PageListData")",callBack: "LoadedInit" });
    }

    function LoadedInit()
    {
        var $lb_can_expand = $(".lb_can_expand");
        var $lb_delete_protect = $(".lb_delete_protect");
        $lb_delete_protect.each(function () {
            var $this = $(this);
            if ($this.html() == "1") {
                $this.html("√");
                $this.parent().parent().find(".ui-deleteSingle").attr("disabled", "disabled");
            }
            else {
                $this.html("-");
            }
        })

        $lb_can_expand.each(function () {
            var $this = $(this);
            if ($this.html() == "1") {
                $this.html("√");
            }
            else {
                $this.html("-");
                $this.parent().parent().find(".btn_field_admin").attr("disabled", "disabled");
            }
        })
    }
    LoadData();


    function BeforeDelete(ids) {
        var arrIds = ids.split(",")
        for (i = 0; i < arrIds.length; i++) {
            if ($("#item_" + arrIds[i]).attr("can_expand") == "1") {
                Alert("启用删除保护的表不能删除，请取消选择！");
                return false;
            }
        }
        return true;

    }
</script>
